Skip to content

fix(cli): require boolean True for OIDC email_verified claim - #7309

Closed
mdabydeen wants to merge 1 commit into
google:mainfrom
mdabydeen:fix/oidc-verified-email-claim
Closed

mdabydeen wants to merge 1 commit into
google:mainfrom
mdabydeen:fix/oidc-verified-email-claim

Conversation

@mdabydeen

Copy link
Copy Markdown
Contributor

Problem

GoogleOidcVerifier.__call__ checks not claims.get("email_verified")
— a Python truthiness check. Any non-empty string is truthy in
Python, so an attacker could bypass the allowlist by supplying a
forged ID token whose email_verified claim serializes to the
string "false" instead of the boolean False.

Solution

Replace not claims.get("email_verified") with
claims.get("email_verified") is not True so only the real
bool(True) satisfies the check. No other claim type can
trick the verifier.

Closes: #7289


Testing Plan

Unit Tests

All 81 tests pass, including 10 new regression tests:

tests/unittests/cli/test_trigger_routes.py   81 passed  2.00s
tests/unittests/cli/                          1219 passed  26.40s

Test class TestEmailVerifiedStrictBoolean covers:

Test Claim value Expected status
test_rejects_string_false_email_verified "false" 403
test_rejects_string_true_email_verified "true" 403
test_rejects_missing_email_verified_claim absent 403
test_rejects_null_email_verified None 403
test_accepts_boolean_true_email_verified True 200
(all of the above × both endpoints)

Manual verification

The regression test test_rejects_string_false_email_verified
fails on main and passes on this branch:

# On main:
FAILED test_rejects_string_false_email_verified[pubsub]
  assert 200 == 403   # string "false" is truthy → accepted

# On this branch:
PASSED  test_rejects_string_false_email_verified[pubsub]

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective.
  • New and existing unit tests pass locally.

Python truthiness treats any non-empty string — including "false" — as
truthy, so the check `not claims.get("email_verified")` accepted forged
ID tokens whose email_verified claim was a string.  An attacker could
bypass the allowlist by supplying a token where email_verified
serializes to "false" instead of the boolean false.

Replace `not claims.get("email_verified")` with
`claims.get("email_verified") is not True` so only the real boolean
True satisfies the check.  Add regression tests covering the string
bypass, a missing claim, and an explicit null.

Fixes google#7289
@GWeale

GWeale commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

thanks @mdabydeen for the fix. the same change landed in 4434070 (#7295), so GoogleOidcVerifier now only accepts a boolean true email_verified. it's on main but not in a release yet. please open a new issue if this is still happening.

@GWeale GWeale closed this Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants